﻿/**
 * Proyecto: Cognitum
 * Global IT Services 2009
 * @author Esanantonio
 */

Cognitum.Polizas.Documento.DataView = Ext.extend(Ext.DataView, {	
	initComponent: function(){
		
		Ext.apply(this, {			               
                autoHeight:true,
                multiSelect: true,
                overClass:'x-view-over',
                itemSelector:'div.thumb-wrap',
                emptyText: 'No hay imagenes para mostrar',
                loadingText: "Cargando....",
				tpl: new Ext.XTemplate('<tpl for=".">', '<div class="thumb-wrap" id="{Id}">', 
					'<tpl if="this.isImage(MimeType) == false">', 
					'<div class="thumb"><img src="Service/DocumentoService.aspx?operation=thumbnail&Id={Id}" title="{Descripcion}"></div>', 
					'</tpl>', '<span class="dataview-nodename">{Nombre}</span></div>', '</tpl>', 
					'<div class="x-clear"></div>', {
                	isImage: function(mime){
                    	return mime == 'image/jpg';
                	}
            	})
		    });
		
		Cognitum.Polizas.Documento.DataView.superclass.initComponent.apply(
			this, arguments);
	    this.addListener('dblclick', this.handleDblClick);
	},
	
	handleDblClick:function( dataview, index, node, e ) {
	    window.open('Service/DocumentoService.aspx?operation=download&Id=' + node.id);
	}
});

Ext.reg('doc.dataview', Cognitum.Polizas.Documento.DataView);


